﻿using QG.FrontDesk.BLL.IService;
using QG.FrontDesk.DAL.IRepository;
using QG.FrontDesk.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QG.FrontDesk.BLL.Service
{
    public class UserInfoService : IUserInfoService
    {
        private IUserInfoRepository userInfoRepository;
        public UserInfoService(IUserInfoRepository userInfoRepository)
        {
            this.userInfoRepository = userInfoRepository;
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public UserInfo Getlogin(UserInfo userInfo)
        {
            return userInfoRepository.Getlogin(userInfo);
        }
        /// <summary>
        /// 注册用户
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public bool AddUserInfo(UserInfo userInfo)
        {
            return userInfoRepository.AddUserInfo(userInfo);
        }
        /// <summary>
        /// 手机验证登录
        /// </summary>
        /// <param name="verificationCode"></param>
        /// <returns></returns>
        public VerificationCode QueryVerificationCode(VerificationCode verificationCode)
        {
            return userInfoRepository.GetMobilelogin(verificationCode);


        }
        /// <summary>
        /// 通过手机号得到用户信息
        /// </summary>
        /// <param name="phone"></param>
        /// <returns></returns>
        public UserInfo GetUserByPhone(string phone)
        {
            return userInfoRepository.GetUserByPhone(phone);
        }
        /// <summary>
        /// 得到对应的用户信息
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public UserInfo GetUserInfo(int Id)
        {
            return userInfoRepository.GetUserInfo(Id);
        }

        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public int UpdateUserInfo(UserInfo userInfo) {
            return userInfoRepository.UpdateUserInfo(userInfo);
        }

        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="oldpassword"></param>
        /// <param name="newpassword"></param>
        /// <returns></returns>
        public int  UpdatePassword(string oldpassword, string newpassword,int userId) {
            return userInfoRepository.UpdatePassword(oldpassword,newpassword,userId);
        }

        /// <summary>
        /// 通过QQ得到用户信息
        /// </summary>
        /// <param name="QQ"></param>
        /// <returns></returns>
        public UserInfo GetUserInfoByQQ(string QQ) {
            return userInfoRepository.GetUserInfoByQQ(QQ);
        }

        /// <summary>
        /// 新增QQ用户
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        public bool AddQQUserInfo(UserInfo userInfo) {
            return userInfoRepository.AddQQUserInfo(userInfo);
        }
    }
}
